package com.ccys.cms.service.healthScreening.impl;


import com.ccys.cms.service.healthScreening.TblS3RootFolderWebService;
import com.ccys.common.vo.ResponseResult;
import com.ccys.db.dto.healthScreening.TblS3RootFolderDTO;
import com.ccys.db.entity.TblS3RootFolder;
import com.ccys.db.mapper.TblS3RootFolderMapper;
import com.ccys.db.page.PageUtils;
import com.ccys.db.rely.service.impl.BaseServiceImpl;
import com.ccys.db.vo.healthScreening.TblS3RootFolderWebVO;

import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;


/**
 * tbl_s3_root_folder管理
 */
@Service
@Slf4j
public class TblS3RootFolderWebServiceImpl extends BaseServiceImpl<TblS3RootFolder> implements TblS3RootFolderWebService {

    @Autowired(required = false)
    private TblS3RootFolderMapper tblS3RootFolderMapper;

    @Override
    public ResponseResult listObjectsCms(HttpServletRequest request, HttpServletResponse response, TblS3RootFolderDTO dto) {
        PageUtils.startPage(request);
        List<TblS3RootFolderWebVO> list = this.tblS3RootFolderMapper.listObjectsCms(dto);
        PageInfo pageInfo = new PageInfo<>(list);
        return ResponseResult.success(pageInfo);
    }


    @Override
    public ResponseResult change(TblS3RootFolder entity) {
        if (StringUtils.isBlank(entity.getId())) {
            // 新增
            this.saveEntity(entity);
        } else {
            // 编辑
            this.updateEntityById(entity);
        }
        return ResponseResult.success();
    }

    @Override
    public ResponseResult delete(TblS3RootFolder dto) {
        TblS3RootFolder entity = new TblS3RootFolder();
        entity.setId(dto.getId());
        entity.setDelFlag(1);
        this.updateEntityById(entity);
        return ResponseResult.success();
    }


}